import MapAssetStruct from "../Structs/MapAssetStruct";
import MainPlayer from "./MainPlayer";
import IEntity from "../Interfaces/IEntity";
import C from "../Configs/Config";
import EntityTypes from "../Constants/EntityTypes";
import MonsterAssetStruct from "../Structs/MonsterAssetStruct";
import IAsset from "../Interfaces/IAsset";

/**
 * 墙的属性组件
 * created by Five on 2018-11-5 12:05:59
 */

export default class EntityStruct implements IEntity {
    Group: number = 2;
    // 唯一id
    public Index: number;
    // 坐标换算成序号
    public Location: number;
    // 资产的信息
    public Asset: any;
    // 血量
    public Blood: number = 1;

    constructor(asset: any, loc: number = 0) {
        if (!C().IsMonster(asset))
            this.Asset = new MapAssetStruct(asset);
        else
            this.Asset = new MonsterAssetStruct(asset);
        this.Location = loc;
    }

    /**
     * 拾取
     * @param who 谁撞的我
     * @return number 撞了我给你啥
     */
    public Attach(who: IEntity): any {
        if (who.Group == this.Group) {
            return [0];
        } else {
            return [1, this.Asset.effect, this.Asset.enumber];
        }
    }

    /**
     * 摧毁掉落
     */
    public Destory(): number {
        if (C().IsTypeOf(this.Asset, EntityTypes.HASDROP)) {
            return this.Asset.enumber;
        }
    }
}
